.class public Lcom/opongo/blogapp/manager/APIManager;
.super Ljava/lang/Object;
.source "APIManager.java"


# static fields
.field public static final DEBUG:Z

.field protected static final TAG:Ljava/lang/String;


# instance fields
.field protected blogApi:Lcom/opongo/blogapp/api/BlogAPI;

.field private context:Landroid/content/Context;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 29
    sget-boolean v0, Lcom/opongo/blogapp/AbaSettings;->DEBUG:Z

    sput-boolean v0, Lcom/opongo/blogapp/manager/APIManager;->DEBUG:Z

    .line 30
    const-class v0, Lcom/opongo/blogapp/manager/APIManager;

    invoke-virtual {v0}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String;

    move-result-object v0

    sput-object v0, Lcom/opongo/blogapp/manager/APIManager;->TAG:Ljava/lang/String;

    .line 26
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .parameter "context"

    .prologue
    .line 35
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 36
    iput-object p1, p0, Lcom/opongo/blogapp/manager/APIManager;->context:Landroid/content/Context;

    .line 37
    new-instance v0, Lcom/opongo/blogapp/api/BlogAPI;

    invoke-direct {v0, p1}, Lcom/opongo/blogapp/api/BlogAPI;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/opongo/blogapp/manager/APIManager;->blogApi:Lcom/opongo/blogapp/api/BlogAPI;

    .line 38
    return-void
.end method

.method public static voteSpicy(IZLandroid/content/Context;)Z
    .locals 7
    .parameter "post_id"
    .parameter "spicy"
    .parameter "c"

    .prologue
    .line 237
    new-instance v0, Lcom/opongo/blogapp/api/BlogAPI;

    invoke-direct {v0, p2}, Lcom/opongo/blogapp/api/BlogAPI;-><init>(Landroid/content/Context;)V

    .line 238
    .local v0, blogApi:Lcom/opongo/blogapp/api/BlogAPI;
    if-eqz p1, :cond_0

    const/4 v6, 0x2

    :goto_0
    invoke-virtual {v0, p0, v6}, Lcom/opongo/blogapp/api/BlogAPI;->sendSpicyDealsVote(II)Lorg/json/JSONObject;

    move-result-object v3

    .line 240
    .local v3, obj:Lorg/json/JSONObject;
    const-string v2, "Deine Bewertung konnte nicht eingetragen werden!"

    .line 243
    .local v2, message:Ljava/lang/String;
    :try_start_0
    const-string v6, "message"

    invoke-virtual {v3, v6}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v2

    .line 249
    :goto_1
    const/4 v6, 0x0

    invoke-static {p2, v2, v6}, Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;

    move-result-object v5

    .line 250
    .local v5, toast:Landroid/widget/Toast;
    invoke-virtual {v5}, Landroid/widget/Toast;->show()V

    .line 252
    const/4 v4, 0x0

    .line 254
    .local v4, success:Z
    :try_start_1
    const-string v6, "rating"

    invoke-virtual {v3, v6}, Lorg/json/JSONObject;->getBoolean(Ljava/lang/String;)Z
    :try_end_1
    .catch Lorg/json/JSONException; {:try_start_1 .. :try_end_1} :catch_1

    move-result v4

    .line 260
    :goto_2
    return v4

    .line 238
    .end local v2           #message:Ljava/lang/String;
    .end local v3           #obj:Lorg/json/JSONObject;
    .end local v4           #success:Z
    .end local v5           #toast:Landroid/widget/Toast;
    :cond_0
    const/4 v6, 0x1

    goto :goto_0

    .line 244
    .restart local v2       #message:Ljava/lang/String;
    .restart local v3       #obj:Lorg/json/JSONObject;
    :catch_0
    move-exception v1

    .line 246
    .local v1, e:Lorg/json/JSONException;
    invoke-virtual {v1}, Lorg/json/JSONException;->printStackTrace()V

    goto :goto_1

    .line 255
    .end local v1           #e:Lorg/json/JSONException;
    .restart local v4       #success:Z
    .restart local v5       #toast:Landroid/widget/Toast;
    :catch_1
    move-exception v1

    .line 257
    .restart local v1       #e:Lorg/json/JSONException;
    invoke-virtual {v1}, Lorg/json/JSONException;->printStackTrace()V

    goto :goto_2
.end method


# virtual methods
.method public addComments(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Lorg/json/JSONObject;
    .locals 8
    .parameter "post_id"
    .parameter "comment"
    .parameter "user_name"
    .parameter "user_email"
    .parameter "user_password"
    .parameter "comment_parent"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lorg/json/JSONException;
        }
    .end annotation

    .prologue
    .line 140
    iget-object v0, p0, Lcom/opongo/blogapp/manager/APIManager;->blogApi:Lcom/opongo/blogapp/api/BlogAPI;

    move v1, p1

    move-object v2, p2

    move-object v3, p3

    move-object v4, p4

    move-object v5, p5

    move v6, p6

    invoke-virtual/range {v0 .. v6}, Lcom/opongo/blogapp/api/BlogAPI;->addComments(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Lorg/json/JSONObject;

    move-result-object v7

    .line 143
    .local v7, result:Lorg/json/JSONObject;
    return-object v7
.end method

.method public addDeal(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/graphics/Bitmap;)Lorg/json/JSONObject;
    .locals 14
    .parameter "spicydeals_name"
    .parameter "spicydeals_title"
    .parameter "spicydeals_content"
    .parameter "spicydeals_price"
    .parameter "spicydeals_link"
    .parameter "spicydeals_date"
    .parameter "spicydeals_code"
    .parameter "spicydeals_discount"
    .parameter "spicydeals_place"
    .parameter "spicydeals_cat"
    .parameter "spicydeals_type"
    .parameter "captureBmp"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lorg/json/JSONException;
        }
    .end annotation

    .prologue
    .line 269
    iget-object v0, p0, Lcom/opongo/blogapp/manager/APIManager;->blogApi:Lcom/opongo/blogapp/api/BlogAPI;

    move-object v1, p1

    move-object/from16 v2, p2

    move-object/from16 v3, p3

    move-object/from16 v4, p4

    move-object/from16 v5, p5

    move-object/from16 v6, p6

    move-object/from16 v7, p7

    move-object/from16 v8, p8

    move-object/from16 v9, p9

    move-object/from16 v10, p10

    move-object/from16 v11, p11

    move-object/from16 v12, p12

    invoke-virtual/range {v0 .. v12}, Lcom/opongo/blogapp/api/BlogAPI;->sendSpicyDealsDeal(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/graphics/Bitmap;)Lorg/json/JSONObject;

    move-result-object v13

    .line 284
    .local v13, result:Lorg/json/JSONObject;
    return-object v13
.end method

.method public getCategories(Lorg/json/JSONArray;)Ljava/lang/String;
    .locals 4
    .parameter "categories"

    .prologue
    .line 164
    const-string v1, ""

    .line 165
    .local v1, categoriesString:Ljava/lang/String;
    if-eqz p1, :cond_0

    .line 167
    :try_start_0
    invoke-virtual {p1}, Lorg/json/JSONArray;->length()I

    move-result v3

    if-lez v3, :cond_0

    .line 168
    const/4 v3, 0x0

    invoke-virtual {p1, v3}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v0

    .line 169
    .local v0, categoriesItem:Lorg/json/JSONObject;
    const-string v3, "name"

    invoke-virtual {v0, v3}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v1

    .line 182
    .end local v0           #categoriesItem:Lorg/json/JSONObject;
    :cond_0
    :goto_0
    return-object v1

    .line 178
    :catch_0
    move-exception v2

    .line 179
    .local v2, e:Lorg/json/JSONException;
    invoke-virtual {v2}, Lorg/json/JSONException;->printStackTrace()V

    goto :goto_0
.end method

.method public getCategories()Lorg/json/JSONArray;
    .locals 2
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lorg/json/JSONException;
        }
    .end annotation

    .prologue
    .line 156
    iget-object v1, p0, Lcom/opongo/blogapp/manager/APIManager;->blogApi:Lcom/opongo/blogapp/api/BlogAPI;

    invoke-virtual {v1}, Lcom/opongo/blogapp/api/BlogAPI;->getCategories()Lorg/json/JSONObject;

    move-result-object v0

    .line 157
    .local v0, result:Lorg/json/JSONObject;
    if-eqz v0, :cond_0

    .line 158
    const-string v1, "categories"

    invoke-virtual {v0, v1}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v1

    .line 160
    :goto_0
    return-object v1

    :cond_0
    const/4 v1, 0x0

    goto :goto_0
.end method

.method public getComments(I)Ljava/util/ArrayList;
    .locals 9
    .parameter "postid"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(I)",
            "Ljava/util/ArrayList",
            "<",
            "Lcom/opongo/blogapp/common/Comment;",
            ">;"
        }
    .end annotation

    .prologue
    .line 105
    new-instance v2, Ljava/util/ArrayList;

    invoke-direct {v2}, Ljava/util/ArrayList;-><init>()V

    .line 106
    .local v2, commentsArray:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/opongo/blogapp/common/Comment;>;"
    iget-object v7, p0, Lcom/opongo/blogapp/manager/APIManager;->blogApi:Lcom/opongo/blogapp/api/BlogAPI;

    invoke-virtual {v7, p1}, Lcom/opongo/blogapp/api/BlogAPI;->getComments(I)Lorg/json/JSONObject;

    move-result-object v6

    .line 107
    .local v6, result:Lorg/json/JSONObject;
    if-eqz v6, :cond_2

    .line 109
    :try_start_0
    const-string v7, "comments"

    invoke-virtual {v6, v7}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v1

    .line 111
    .local v1, comments:Lorg/json/JSONArray;
    const/4 v5, 0x0

    .local v5, i:I
    :goto_0
    invoke-virtual {v1}, Lorg/json/JSONArray;->length()I

    move-result v7

    if-lt v5, v7, :cond_0

    .line 133
    .end local v1           #comments:Lorg/json/JSONArray;
    .end local v2           #commentsArray:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/opongo/blogapp/common/Comment;>;"
    .end local v5           #i:I
    :goto_1
    return-object v2

    .line 112
    .restart local v1       #comments:Lorg/json/JSONArray;
    .restart local v2       #commentsArray:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/opongo/blogapp/common/Comment;>;"
    .restart local v5       #i:I
    :cond_0
    invoke-virtual {v1, v5}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v3

    .line 114
    .local v3, commentsItem:Lorg/json/JSONObject;
    new-instance v0, Lcom/opongo/blogapp/common/Comment;

    invoke-direct {v0}, Lcom/opongo/blogapp/common/Comment;-><init>()V

    .line 115
    .local v0, c:Lcom/opongo/blogapp/common/Comment;
    const-string v7, "comment_ID"

    invoke-virtual {v3, v7}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v7

    iput v7, v0, Lcom/opongo/blogapp/common/Comment;->id:I

    .line 116
    const-string v7, "comment_parent"

    invoke-virtual {v3, v7}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v7

    iput v7, v0, Lcom/opongo/blogapp/common/Comment;->parent:I

    .line 117
    const-string v7, "comment_post_ID"

    invoke-virtual {v3, v7}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v7

    iput v7, v0, Lcom/opongo/blogapp/common/Comment;->postId:I

    .line 118
    const-string v7, "comment_content"

    invoke-virtual {v3, v7}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    iput-object v7, v0, Lcom/opongo/blogapp/common/Comment;->content:Ljava/lang/String;

    .line 119
    const-string v7, "comment_author"

    invoke-virtual {v3, v7}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    iput-object v7, v0, Lcom/opongo/blogapp/common/Comment;->author:Ljava/lang/String;

    .line 120
    const-string v7, "comment_date"

    invoke-virtual {v3, v7}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    iput-object v7, v0, Lcom/opongo/blogapp/common/Comment;->date:Ljava/lang/String;

    .line 121
    const-string v7, "comment_gravatar"

    invoke-virtual {v3, v7}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    iput-object v7, v0, Lcom/opongo/blogapp/common/Comment;->gravatarUrl:Ljava/lang/String;

    .line 122
    invoke-virtual {v2, v0}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0

    .line 111
    add-int/lit8 v5, v5, 0x1

    goto :goto_0

    .line 126
    .end local v0           #c:Lcom/opongo/blogapp/common/Comment;
    .end local v1           #comments:Lorg/json/JSONArray;
    .end local v3           #commentsItem:Lorg/json/JSONObject;
    .end local v5           #i:I
    :catch_0
    move-exception v4

    .line 127
    .local v4, e:Lorg/json/JSONException;
    sget-boolean v7, Lcom/opongo/blogapp/manager/APIManager;->DEBUG:Z

    if-eqz v7, :cond_1

    .line 128
    sget-object v7, Lcom/opongo/blogapp/manager/APIManager;->TAG:Ljava/lang/String;

    const-string v8, "Error processing JSON result"

    invoke-static {v7, v8}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 129
    :cond_1
    sget-boolean v7, Lcom/opongo/blogapp/manager/APIManager;->DEBUG:Z

    if-eqz v7, :cond_2

    .line 130
    invoke-virtual {v4}, Lorg/json/JSONException;->printStackTrace()V

    .line 133
    .end local v4           #e:Lorg/json/JSONException;
    :cond_2
    const/4 v2, 0x0

    goto :goto_1
.end method

.method public getMostReadPosts()Ljava/util/ArrayList;
    .locals 6
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/ArrayList",
            "<",
            "Lcom/opongo/blogapp/common/Post;",
            ">;"
        }
    .end annotation

    .prologue
    const/4 v1, 0x1

    .line 49
    const/16 v3, 0x14

    const/4 v4, 0x0

    const/4 v5, -0x1

    move-object v0, p0

    move v2, v1

    invoke-virtual/range {v0 .. v5}, Lcom/opongo/blogapp/manager/APIManager;->getPosts(IIILjava/lang/String;I)Ljava/util/ArrayList;

    move-result-object v0

    return-object v0
.end method

.method public getPosts(IIILjava/lang/String;I)Ljava/util/ArrayList;
    .locals 15
    .parameter "type"
    .parameter "page"
    .parameter "postsPerPage"
    .parameter "searchString"
    .parameter "cat_id"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(III",
            "Ljava/lang/String;",
            "I)",
            "Ljava/util/ArrayList",
            "<",
            "Lcom/opongo/blogapp/common/Post;",
            ">;"
        }
    .end annotation

    .prologue
    .line 54
    new-instance v11, Ljava/util/ArrayList;

    invoke-direct {v11}, Ljava/util/ArrayList;-><init>()V

    .line 56
    .local v11, postArray:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/opongo/blogapp/common/Post;>;"
    new-instance v7, Lcom/opongo/blogapp/manager/DatabaseManager;

    iget-object v0, p0, Lcom/opongo/blogapp/manager/APIManager;->context:Landroid/content/Context;

    .line 57
    const-string v1, "categories"

    const-string v2, "INSERT INTO categories (id,cat_name,cat_parent,cat_enable,cat_new,cat_child_count,cat_show_enable) VALUES (?,?,?,?,?,?,?);"

    .line 56
    invoke-direct {v7, v0, v1, v2}, Lcom/opongo/blogapp/manager/DatabaseManager;-><init>(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V

    .line 59
    .local v7, dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;
    const/4 v0, 0x0

    invoke-virtual {v7, v0}, Lcom/opongo/blogapp/manager/DatabaseManager;->getCategoriesStatusAsJSON(Z)Ljava/lang/String;

    move-result-object v6

    .line 60
    .local v6, categories:Ljava/lang/String;
    iget-object v0, p0, Lcom/opongo/blogapp/manager/APIManager;->blogApi:Lcom/opongo/blogapp/api/BlogAPI;

    move/from16 v1, p1

    move/from16 v2, p2

    move/from16 v3, p3

    move-object/from16 v4, p4

    move/from16 v5, p5

    invoke-virtual/range {v0 .. v6}, Lcom/opongo/blogapp/api/BlogAPI;->showPosts(IIILjava/lang/String;ILjava/lang/String;)Lorg/json/JSONObject;

    move-result-object v14

    .line 62
    .local v14, result:Lorg/json/JSONObject;
    invoke-virtual {v7}, Lcom/opongo/blogapp/manager/DatabaseManager;->close()V

    .line 64
    if-eqz v14, :cond_5

    .line 66
    :try_start_0
    const-string v0, "items"

    invoke-virtual {v14, v0}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v13

    .line 68
    .local v13, posts:Lorg/json/JSONArray;
    const/4 v9, 0x0

    .local v9, i:I
    :goto_0
    invoke-virtual {v13}, Lorg/json/JSONArray;->length()I

    move-result v0

    if-lt v9, v0, :cond_0

    .line 101
    .end local v9           #i:I
    .end local v11           #postArray:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/opongo/blogapp/common/Post;>;"
    .end local v13           #posts:Lorg/json/JSONArray;
    :goto_1
    return-object v11

    .line 69
    .restart local v9       #i:I
    .restart local v11       #postArray:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/opongo/blogapp/common/Post;>;"
    .restart local v13       #posts:Lorg/json/JSONArray;
    :cond_0
    invoke-virtual {v13, v9}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v12

    .line 71
    .local v12, postItem:Lorg/json/JSONObject;
    new-instance v10, Lcom/opongo/blogapp/common/Post;

    invoke-direct {v10}, Lcom/opongo/blogapp/common/Post;-><init>()V

    .line 72
    .local v10, p:Lcom/opongo/blogapp/common/Post;
    const-string v0, "ID"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v0

    iput v0, v10, Lcom/opongo/blogapp/common/Post;->id:I

    .line 73
    const-string v0, "post_content"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, v10, Lcom/opongo/blogapp/common/Post;->content:Ljava/lang/String;

    .line 74
    const-string v0, "post_title"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, v10, Lcom/opongo/blogapp/common/Post;->title:Ljava/lang/String;

    .line 75
    const-string v0, "post_date"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, v10, Lcom/opongo/blogapp/common/Post;->date:Ljava/lang/String;

    .line 77
    const-string v0, "categories"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v0

    .line 76
    invoke-virtual {p0, v0}, Lcom/opongo/blogapp/manager/APIManager;->getCategories(Lorg/json/JSONArray;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, v10, Lcom/opongo/blogapp/common/Post;->categories:Ljava/lang/String;

    .line 78
    const-string v0, "comment_count"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v0

    iput v0, v10, Lcom/opongo/blogapp/common/Post;->commentsCount:I

    .line 79
    const-string v0, "post_image_thumbnail"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, v10, Lcom/opongo/blogapp/common/Post;->imageUrl:Ljava/lang/String;

    .line 80
    const-string v0, "post_order"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v0

    iput v0, v10, Lcom/opongo/blogapp/common/Post;->order:I

    .line 81
    const-string v0, "guid"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, v10, Lcom/opongo/blogapp/common/Post;->guid:Ljava/lang/String;

    .line 82
    const/4 v0, 0x0

    iput v0, v10, Lcom/opongo/blogapp/common/Post;->opened:I

    .line 84
    const-string v0, "post_author"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->has(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_1

    .line 85
    const-string v0, "post_author"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 84
    :goto_2
    iput-object v0, v10, Lcom/opongo/blogapp/common/Post;->post_author:Ljava/lang/String;

    .line 86
    const-string v0, "post_price"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->has(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_2

    .line 87
    const-string v0, "post_price"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->getDouble(Ljava/lang/String;)D

    move-result-wide v0

    .line 86
    :goto_3
    iput-wide v0, v10, Lcom/opongo/blogapp/common/Post;->post_price:D

    .line 88
    const-string v0, "post_rating"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->has(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_3

    .line 89
    const-string v0, "post_rating"

    invoke-virtual {v12, v0}, Lorg/json/JSONObject;->getDouble(Ljava/lang/String;)D

    move-result-wide v0

    .line 88
    :goto_4
    iput-wide v0, v10, Lcom/opongo/blogapp/common/Post;->post_rating:D

    .line 91
    invoke-virtual {v11, v10}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 68
    add-int/lit8 v9, v9, 0x1

    goto/16 :goto_0

    .line 85
    :cond_1
    const-string v0, ""
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_2

    .line 87
    :cond_2
    const-wide/16 v0, 0x0

    goto :goto_3

    .line 89
    :cond_3
    const-wide/16 v0, 0x0

    goto :goto_4

    .line 94
    .end local v9           #i:I
    .end local v10           #p:Lcom/opongo/blogapp/common/Post;
    .end local v12           #postItem:Lorg/json/JSONObject;
    .end local v13           #posts:Lorg/json/JSONArray;
    :catch_0
    move-exception v8

    .line 95
    .local v8, e:Lorg/json/JSONException;
    sget-boolean v0, Lcom/opongo/blogapp/manager/APIManager;->DEBUG:Z

    if-eqz v0, :cond_4

    .line 96
    sget-object v0, Lcom/opongo/blogapp/manager/APIManager;->TAG:Ljava/lang/String;

    const-string v1, "Error processing JSON result"

    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 97
    :cond_4
    sget-boolean v0, Lcom/opongo/blogapp/manager/APIManager;->DEBUG:Z

    if-eqz v0, :cond_5

    .line 98
    invoke-virtual {v8}, Lorg/json/JSONException;->printStackTrace()V

    .line 101
    .end local v8           #e:Lorg/json/JSONException;
    :cond_5
    const/4 v11, 0x0

    goto/16 :goto_1
.end method

.method public getRecentPosts()Ljava/util/ArrayList;
    .locals 6
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/ArrayList",
            "<",
            "Lcom/opongo/blogapp/common/Post;",
            ">;"
        }
    .end annotation

    .prologue
    .line 45
    const/4 v1, 0x0

    const/4 v2, 0x1

    const/16 v3, 0x14

    const/4 v4, 0x0

    const/4 v5, -0x1

    move-object v0, p0

    invoke-virtual/range {v0 .. v5}, Lcom/opongo/blogapp/manager/APIManager;->getPosts(IIILjava/lang/String;I)Ljava/util/ArrayList;

    move-result-object v0

    return-object v0
.end method

.method public getSpicyDeals(IIILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/util/ArrayList;
    .locals 14
    .parameter "type"
    .parameter "page"
    .parameter "postsPerPage"
    .parameter "order"
    .parameter "range"
    .parameter "searchString"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(III",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ")",
            "Ljava/util/ArrayList",
            "<",
            "Lcom/opongo/blogapp/common/Post;",
            ">;"
        }
    .end annotation

    .prologue
    .line 191
    new-instance v10, Ljava/util/ArrayList;

    invoke-direct {v10}, Ljava/util/ArrayList;-><init>()V

    .line 193
    .local v10, postArray:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/opongo/blogapp/common/Post;>;"
    iget-object v0, p0, Lcom/opongo/blogapp/manager/APIManager;->blogApi:Lcom/opongo/blogapp/api/BlogAPI;

    move v1, p1

    move/from16 v2, p2

    move/from16 v3, p3

    move-object/from16 v4, p4

    move-object/from16 v5, p5

    move-object/from16 v6, p6

    invoke-virtual/range {v0 .. v6}, Lcom/opongo/blogapp/api/BlogAPI;->showSpicyDeals(IIILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object v13

    .line 196
    .local v13, result:Lorg/json/JSONObject;
    if-eqz v13, :cond_5

    .line 198
    :try_start_0
    const-string v0, "items"

    invoke-virtual {v13, v0}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v12

    .line 200
    .local v12, posts:Lorg/json/JSONArray;
    const/4 v8, 0x0

    .local v8, i:I
    :goto_0
    invoke-virtual {v12}, Lorg/json/JSONArray;->length()I

    move-result v0

    if-lt v8, v0, :cond_0

    .line 233
    .end local v8           #i:I
    .end local v10           #postArray:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/opongo/blogapp/common/Post;>;"
    .end local v12           #posts:Lorg/json/JSONArray;
    :goto_1
    return-object v10

    .line 201
    .restart local v8       #i:I
    .restart local v10       #postArray:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/opongo/blogapp/common/Post;>;"
    .restart local v12       #posts:Lorg/json/JSONArray;
    :cond_0
    invoke-virtual {v12, v8}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v11

    .line 203
    .local v11, postItem:Lorg/json/JSONObject;
    new-instance v9, Lcom/opongo/blogapp/common/Post;

    invoke-direct {v9}, Lcom/opongo/blogapp/common/Post;-><init>()V

    .line 204
    .local v9, p:Lcom/opongo/blogapp/common/Post;
    const-string v0, "ID"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v0

    iput v0, v9, Lcom/opongo/blogapp/common/Post;->id:I

    .line 205
    const-string v0, "post_content"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, v9, Lcom/opongo/blogapp/common/Post;->content:Ljava/lang/String;

    .line 206
    const-string v0, "post_title"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, v9, Lcom/opongo/blogapp/common/Post;->title:Ljava/lang/String;

    .line 207
    const-string v0, "post_date"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, v9, Lcom/opongo/blogapp/common/Post;->date:Ljava/lang/String;

    .line 209
    const-string v0, "categories"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;

    move-result-object v0

    .line 208
    invoke-virtual {p0, v0}, Lcom/opongo/blogapp/manager/APIManager;->getCategories(Lorg/json/JSONArray;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, v9, Lcom/opongo/blogapp/common/Post;->categories:Ljava/lang/String;

    .line 210
    const-string v0, "comment_count"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v0

    iput v0, v9, Lcom/opongo/blogapp/common/Post;->commentsCount:I

    .line 211
    const-string v0, "post_image_thumbnail"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, v9, Lcom/opongo/blogapp/common/Post;->imageUrl:Ljava/lang/String;

    .line 212
    const-string v0, "post_order"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getInt(Ljava/lang/String;)I

    move-result v0

    iput v0, v9, Lcom/opongo/blogapp/common/Post;->order:I

    .line 213
    const-string v0, "guid"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, v9, Lcom/opongo/blogapp/common/Post;->guid:Ljava/lang/String;

    .line 214
    const/4 v0, 0x0

    iput v0, v9, Lcom/opongo/blogapp/common/Post;->opened:I

    .line 216
    const-string v0, "post_author"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->has(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_1

    .line 217
    const-string v0, "post_author"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 216
    :goto_2
    iput-object v0, v9, Lcom/opongo/blogapp/common/Post;->post_author:Ljava/lang/String;

    .line 218
    const-string v0, "post_price"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->has(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_2

    .line 219
    const-string v0, "post_price"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getDouble(Ljava/lang/String;)D

    move-result-wide v0

    .line 218
    :goto_3
    iput-wide v0, v9, Lcom/opongo/blogapp/common/Post;->post_price:D

    .line 220
    const-string v0, "post_rating"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->has(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_3

    .line 221
    const-string v0, "post_rating"

    invoke-virtual {v11, v0}, Lorg/json/JSONObject;->getDouble(Ljava/lang/String;)D

    move-result-wide v0

    .line 220
    :goto_4
    iput-wide v0, v9, Lcom/opongo/blogapp/common/Post;->post_rating:D

    .line 223
    invoke-virtual {v10, v9}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 200
    add-int/lit8 v8, v8, 0x1

    goto/16 :goto_0

    .line 217
    :cond_1
    const-string v0, ""
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_2

    .line 219
    :cond_2
    const-wide/16 v0, 0x0

    goto :goto_3

    .line 221
    :cond_3
    const-wide/16 v0, 0x0

    goto :goto_4

    .line 226
    .end local v8           #i:I
    .end local v9           #p:Lcom/opongo/blogapp/common/Post;
    .end local v11           #postItem:Lorg/json/JSONObject;
    .end local v12           #posts:Lorg/json/JSONArray;
    :catch_0
    move-exception v7

    .line 227
    .local v7, e:Lorg/json/JSONException;
    sget-boolean v0, Lcom/opongo/blogapp/manager/APIManager;->DEBUG:Z

    if-eqz v0, :cond_4

    .line 228
    sget-object v0, Lcom/opongo/blogapp/manager/APIManager;->TAG:Ljava/lang/String;

    const-string v1, "Error processing JSON result"

    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 229
    :cond_4
    sget-boolean v0, Lcom/opongo/blogapp/manager/APIManager;->DEBUG:Z

    if-eqz v0, :cond_5

    .line 230
    invoke-virtual {v7}, Lorg/json/JSONException;->printStackTrace()V

    .line 233
    .end local v7           #e:Lorg/json/JSONException;
    :cond_5
    const/4 v10, 0x0

    goto/16 :goto_1
.end method

.method public registerUser(Ljava/lang/String;)I
    .locals 1
    .parameter "deviceToken"

    .prologue
    .line 41
    iget-object v0, p0, Lcom/opongo/blogapp/manager/APIManager;->blogApi:Lcom/opongo/blogapp/api/BlogAPI;

    invoke-virtual {v0, p1}, Lcom/opongo/blogapp/api/BlogAPI;->registerUser(Ljava/lang/String;)I

    move-result v0

    return v0
.end method

.method public saveCategoriesOnServer(Ljava/lang/String;)Lorg/json/JSONObject;
    .locals 1
    .parameter "json_string"

    .prologue
    .line 186
    iget-object v0, p0, Lcom/opongo/blogapp/manager/APIManager;->blogApi:Lcom/opongo/blogapp/api/BlogAPI;

    invoke-virtual {v0, p1}, Lcom/opongo/blogapp/api/BlogAPI;->saveCategoriesOnServer(Ljava/lang/String;)Lorg/json/JSONObject;

    move-result-object v0

    return-object v0
.end method

.method public setNighttime(Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;I)Lorg/json/JSONObject;
    .locals 7
    .parameter "nighttime_from"
    .parameter "nighttime_to"
    .parameter "b"
    .parameter "sound"
    .parameter "spicyDealsTemp"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lorg/json/JSONException;
        }
    .end annotation

    .prologue
    .line 149
    iget-object v0, p0, Lcom/opongo/blogapp/manager/APIManager;->blogApi:Lcom/opongo/blogapp/api/BlogAPI;

    move-object v1, p1

    move-object v2, p2

    move v3, p3

    move-object v4, p4

    move v5, p5

    invoke-virtual/range {v0 .. v5}, Lcom/opongo/blogapp/api/BlogAPI;->setNighttime(Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;I)Lorg/json/JSONObject;

    move-result-object v6

    .line 152
    .local v6, result:Lorg/json/JSONObject;
    return-object v6
.end method
